package book_management.user;

import book_management.operation.IOperation;
import book_management.operation.impl.*;

import java.util.Scanner;

public class Admin extends User{
    private Scanner scanner = new Scanner(System.in);

    public Admin(String name) {
        this.name = name;
        //管理员登录可以使用的接口权限
        this.iOperations = new IOperation[]{
                //添加书籍
                new AddOperation(),
                //删除书籍
                new RemoveOperation(),
                //更新书籍
                new UpdateOperation(),
                //查询书籍
                new FindOperation(),
                //查看书籍列表
                new ListOperation()
        };
    }

    @Override
    public int menu() {
        System.out.println("=============================");
        System.out.println("欢迎"+this.name+"登录图书管理系统");
        System.out.println("1.添加书籍");
        System.out.println("2.删除书籍");
        System.out.println("3.更新书籍");
        System.out.println("4.查询书籍");
        System.out.println("5.查看书籍列表");
        System.out.println("-1,退出系统");
        System.out.println("请输入你的选择：");
        int choice = scanner.nextInt();
        if (choice==-1){
            //关闭输入
            scanner.close();
        }
        System.out.println("=============================");
        return choice;
    }
}
